package com.ljq.cksp.exception;

import com.ljq.cksp.pojo.Result;
import com.ljq.cksp.pojo.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author:ljq
 * @Date:2019/12/8
 */

@ControllerAdvice
public class GlobalExcrptionHandler {
    @ExceptionHandler(value = Exception.class)
    public Result defaultErrorHandler(HttpServletRequest req, Exception e)throws Exception{
        Result result = new Result();
        result.setMsg("服务器发生未知错误");
        result.setStatus(StatusCode.SERVICEERROR);
        return result;
    }
}
